//
// Override the DeleteButton_Click() button handler method. Add custom logic that gets executed
// on ${Button Control}_Click
//
public override void ${Button Control}_Click(object sender, ImageClickEventArgs args)
{
try
{
DbUtils.StartTransaction();
${Table Control}Row[] reclist = this.GetSelectedRecordControls();
// Loop through each selected record
foreach (${Table Control}Row rec in reclist)
{
// If the field contains value "11111", then the deletion of the record is cancelled and an error message is displayed; otherwise, the
// selected record is deleted
if (rec.${Field Value Control}.Text.Equals("11111"))
{
BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "Cannot delete record", "Cannot delete record with ${Field Value Control} = " + rec.${Field Value Control}.Text);
//Set the selection of the record to false so that the deletion of the record does not takes place.
rec.${Table Name}RecordRowSelection.Checked = false;
}
}
this.DeleteSelectedRecords(false);
this.Page.CommitTransaction(sender);
}catch (Exception ex) {
BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "BUTTON_CLICK_MESSAGE", ex.Message);
this.Page.RollBackTransaction(sender);
} finally {
DbUtils.EndTransaction();
}
}
|